package com.achun.ximalayamvvm.vm

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.achun.ximalayamvvm.model.ServiceApi
import com.achun.ximalayamvvm.utils.Constants
import com.achun.ximalayamvvm.utils.LogUtil
import com.ximalaya.ting.android.opensdk.constants.DTransferConstants
import com.ximalaya.ting.android.opensdk.datatrasfer.CommonRequest
import com.ximalaya.ting.android.opensdk.datatrasfer.IDataCallBack
import com.ximalaya.ting.android.opensdk.model.album.Album
import com.ximalaya.ting.android.opensdk.model.album.GussLikeAlbumList

class MusicIndexViewModel:ViewModel() {
    //创建一个liveData
 private var albumList=MutableLiveData<List<Album>>()
    var requestCode=MutableLiveData<Int>()
    //获取推荐列表
   fun loadrecommendList(){
        requestCode.value=Constants.LOAD_CODE
       ServiceApi.instance.getRecommendList(object :IDataCallBack<GussLikeAlbumList>{
           override fun onSuccess(p0: GussLikeAlbumList?) {
               albumList?.value = p0?.albumList
               requestCode.value=Constants.SUCCESS_CODE
               LogUtil.e(this,"推荐列表--》${albumList?.toString()}")
           }

           override fun onError(p0: Int, p1: String?) {
               LogUtil.e(this,"网络错误--》$p1")
               requestCode.value=Constants.ERROR_CODE
           }

       })

   }
    fun getrecommendList():MutableLiveData<List<Album>>?{
        return albumList;
    }


}